import Taro, { Component } from '@tarojs/taro'
import { View, Text, Image, Picker, Swiper, SwiperItem } from '@tarojs/components'
import {AtList,AtListItem} from 'taro-ui'
import './wangqihuati.scss'
import { $navigateTo, getGlobalData } from '../../../../global';
import reactMixin from 'react-mixin';
import myJs from './wangqihuatiJs.js'
import app from '../../../../main.js'

export default class Wangqihuati extends Component {
    config = {
        navigationBarTitleText: '往期话题'
    }
    constructor () { 
        super(...arguments); 
        this.state = this.getData(); 
    }
    init() {
        this.listTopics();
        console.log(this.state.topicss)
    }
    onReachBottom() {
        // 分页逻辑,下拉到底部触发时间
        if (this.state.total > this.state.dongtaiss.offset) {
            this.state.topicss.offset += this.state.topicss.length;
            this.listTopics();
            console.log(this.state.topicss)
        }
    }
    go(url){
        $navigateTo(url);
    }
    render () {
        return (
            <View className='wangqihuati'>
                <AtList>
                    {
                        this.state.topicss.items.map((item,index)=>{
                            return (
                                <AtListItem 
                                 key={index}
                                 onClick={this.go.bind(this,'../huati/huati?id='+item.id)} 
                                 title={item.title}
                                 note={'讨论数：'+item.commentNum} 
                                 extraText='详情' 
                                 arrow='right' 
                                 thumb={app.getPath(item.image)}
                                 ></AtListItem>
                            );
                        })
                    }
                </AtList>
            </View>
        );
    }
}
reactMixin.onClass(Wangqihuati,myJs);